<template>
  <footer class="footer">
    <span class="todo-count"
      >剩余<strong> {{ length }}</strong></span
    >
    <ul class="filters">
      <li>
        <a
          :class="{ selected: actives === 'all' }"
          @click="eDl('all')"
          href="javascript:;"
          >全部</a
        >
      </li>
      <li>
        <a
          :class="{ selected: actives === 'active' }"
          @click="eDl('active')"
          href="javascript:;"
          >未完成</a
        >
      </li>
      <li>
        <a
          :class="{ selected: actives === 'over' }"
          @click="eDl('over')"
          href="javascript:;"
          >已完成</a
        >
      </li>
    </ul>
    <button class="clear-completed" v-show="showFn" @click="out">
      清除已完成
    </button>
  </footer>
</template>

<script>
export default {
  data() {
    return {
      actives: "all",
    };
  },
  props: {
    arr: {
      type: Array,
      required: true,
    },
  },
  methods: {
    eDl(val) {
      this.actives = val;
      this.$emit("eDl", val);
    },
    out() {
      this.$emit("outs");
    },
  },
  computed: {
    length() {
      // console.log(this.arr);
      return this.arr.filter((item) => item.isDone === false).length;
    },
    showFn() {
      return this.arr.some((item) => item.isDone === true);
    },
  },
};
</script>
